package com.Controller;
import com.Service.FindBookService;
import com.pojo.FindBook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Collections;
import java.util.List;

@Controller("/")
public class IndexController {
    @Autowired
    FindBookService findBookService;
    @RequestMapping("/")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("books");
        List<FindBook> allBooks = findBookService.findAllBooks();
        Collections.shuffle(allBooks);
        modelAndView.addObject("allbook", allBooks);
        return modelAndView;
    }
}
